<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<!--Converted with LaTeX2HTML 96.1 (Feb 5, 1996) by Nikos Drakos (nikos@cbl.leeds.ac.uk), CBLU, University of Leeds -->


<title>Count on Cantor</title>
<meta name="description" content="Count on Cantor">
<meta name="keywords" content="htmlatex">
<meta name="resource-type" content="document">
<meta name="distribution" content="global">
<link rel="STYLESHEET" href="acm-00264_archivos/htmlatex.css">
</head><body bgcolor="#ffffff" lang="EN">
 <h1><br clear="all"><center><table bgcolor="#0060f0"><tbody><tr><td><b><font color="#c0ffff" size="5">&nbsp;<a name="SECTION0001000000000000000000">Count on Cantor</a></font>&nbsp;</b></td></tr></tbody></table></center></h1>
<p>
One of the famous proofs of modern mathematics is Georg Cantor's demonstration
that the set of rational numbers is enumerable. The proof works by using
an explicit enumeration of rational numbers as shown in the diagram below.
</p><p>
</p><p> <img alt="displaymath27" src="acm-00264_archivos/264img1.gif" align="bottom" height="104" width="365"> </p><p>
</p><p>
In the above diagram, the first term is 1/1, the second term is 1/2, the
third term is 2/1, the fourth term is 3/1, the fifth term is 2/2, and so
on.
</p><p>
</p><h2><font color="#0070e8"><a name="SECTION0001001000000000000000">Input and Output</a></font></h2>
<p>
You are to write a program that will read a list of numbers in the range
from 1 to  <img alt="tex2html_wrap_inline29" src="acm-00264_archivos/264img2.gif" align="bottom" height="16" width="24">  and will print for each number the corresponding term in
Cantor's enumeration as given below. No blank line should appear after the
last number.
</p><p>
</p><p>
The input list contains a single number per line and will be
terminated by end-of-file.
</p><p>
</p><h2><font color="#0070e8"><a name="SECTION0001002000000000000000">Sample input</a></font></h2>
<p>
</p><pre>3
14
7</pre>
<p>
</p><h2><font color="#0070e8"><a name="SECTION0001003000000000000000">Sample output</a></font></h2>
<p>
</p><pre>TERM 3 IS 2/1
TERM 14 IS 2/4
TERM 7 IS 1/4</pre>
<p>
</p></body></html>